package com.kuang.demo.controller.wx;

import com.kuang.demo.bean.BaseRespVo;
import com.kuang.demo.bean.wx.WXStorageUpload;
import com.kuang.demo.service.wx.WXStorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("wx/storage")
public class WXStorageController {
    @Autowired
    WXStorageService wxStorageService;

    @PostMapping("upload")
    public BaseRespVo storageUpload(MultipartFile file, HttpServletRequest request) {
        StringBuffer requestURL = request.getRequestURL();
        String url = String.valueOf(requestURL).replace("wx/storage/upload", "");
        WXStorageUpload WXStorageUpload = wxStorageService.upload(url,file);
//        goodsService.createPic(url, file);
        return BaseRespVo.ok(WXStorageUpload);

    }
}
